package jj.fly.activiti.leavebill.service.impl;

import jj.fly.activiti.leavebill.dao.mybatis.EmployeeMapper;
import jj.fly.activiti.leavebill.domain.Employee;
import jj.fly.activiti.leavebill.domain.EmployeeExample;
import jj.fly.activiti.leavebill.service.IEmployeeService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author: jiangjun
 * Date: 2018/5/8
 * Time: 下午10:19
 * Description:
 */
@Service("employeeService")
public class EmployeeServiceImpl implements IEmployeeService {

    @Autowired
    private EmployeeMapper mapper;

    @Override
    public Employee getDataByName(String name) {
        EmployeeExample example = new EmployeeExample();
        example.or().andNameEqualTo(name);
        List<Employee> employees = mapper.selectByExample(example);
        if(!CollectionUtils.isEmpty(employees)){
            return employees.get(0);
        }
        return null;
    }

    @Override
    public Employee getDataById(Integer managerId) {
        return mapper.selectByPrimaryKey(managerId);
    }
}
